nums = [1, 2, 3]

def permute(pos, end):
    if pos == end:
        print(nums)
        return

    for i in range(pos, end):
        nums[i], nums[pos] = nums[pos], nums[i]
        permute(pos + 1, end)
        nums[i], nums[pos] = nums[pos], nums[i]

permute(0, len(nums))
